package com.liushao.controller.admin;


import com.liushao.entity.Lend;
import com.liushao.result.Result;
import com.liushao.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author chen
 * @since 2025-01-03
 */
@Api(tags = "标的管理")
@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {

    @Autowired
    private LendService lendService;

    //http://localhost/admin/core/lend/list

    @GetMapping("/list")
    public Result list(){
          List<Lend> lendList= lendService.selectList();
        return  Result.ok().data("list",lendList);
    }


    ///admin/core/lend/show/${id}

    @GetMapping("/show/{id}")
    public Result show(
            @ApiParam(value = "标的id",required = true)
            @PathVariable Long id
    ){

       Map<String,Object> map= lendService.getLendDetailById(id);

       return  Result.ok().data("lendDetail",map);

    }

    /*
            makeLoan(id) {
        return request({
          url: `/admin/core/lend/makeLoan/${id}`,
          method: 'get'
        })
      }
     */

    @GetMapping("/makeLoan/{id}")
    public Result makeLoan(
            @ApiParam(value = "标的的id",required = true)
            @PathVariable Long id
    ){
        lendService.makeLoan(id);

        return  Result.ok().message("放款成功!");

    }

}

